package com.health.work.adapter;

import java.io.File;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;

import com.health.work.R;
import com.health.work.model.QuestionBean;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Environment;
import android.text.Html;
import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

/**
 * @author AW
 * 收藏夹适配器
 */
public class QuestionListAdapter extends BaseAdapter {
	private ArrayList<QuestionBean> list;
	Activity context;
	ListView lv;
	String s;// 编写html语句
	Spanned ss;// 为不同的字体设置不同的颜色
	private LayoutInflater inflater;
	private String filePath;
	private boolean isEdit = false;	

	public void setEdit(boolean isEdit) {
		this.isEdit = isEdit;
	}
	
	/**
	 * @param context Activity
	 * @param objects list对象
	 * @param lv 显示的listview
	 */
	public QuestionListAdapter(Context context,ArrayList<QuestionBean> objects,ListView lv) {
		this.list = objects;
		this.context = (Activity)context;
		this.lv = lv;
		inflater = this.context.getLayoutInflater();
	//	filePath = Environment.getExternalStorageDirectory()+ "/mbaobao/favorite/";
	}
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHodler viewHodler;
		if(convertView==null) {
			viewHodler = new ViewHodler();
			convertView = inflater.inflate(R.layout.question_item, parent, false);
			viewHodler.itemName = (TextView) convertView.findViewById(R.id.question);
			viewHodler.state = (TextView) convertView.findViewById(R.id.state);
			convertView.setTag(viewHodler);
		} else {
			viewHodler = (ViewHodler) convertView.getTag();
		}
		QuestionBean bean=list.get(position);
		viewHodler.itemName.setText(bean.Question);
		viewHodler.state.setText(bean.State);
		
		convertView.setTag(viewHodler);
		return convertView;
	}
	class ViewHodler {
		public TextView itemName;        //问题
		public TextView state;        //状态
	}
}
